<template>
	<div>
		<city-header></city-header>
		<city-search :cities="cities"></city-search>
		<city-list :hot="hotCities" :cities="cities" :letter="letter"></city-list>
		<city-nav :cities="cities" @change="handleClickChange"></city-nav>
	</div>	
</template>

<script>
	import axios from 'axios'
	import CityHeader from './components/header'
	import CitySearch from './components/search'
	import CityList from './components/list'
	import CityNav from './components/nav'
	export default{
		components:{
			CityHeader,
			CitySearch,
			CityList,
			CityNav
		},
		data(){
			return{
				hotCities : [],
				cities    : {},
				letter    : ''
			}
		},
		methods:{
			getCityInfo(){
				axios.get('/api/city.json').then(this.getCityInfoSucc)
			},
			getCityInfoSucc(res){
				res = res.data
				if(res.ret && res.data){
					const data = res.data
					this.hotCities = data.hotCities
					this.cities    = data.cities
				}
			},
			handleClickChange(letter){
				this.letter = letter
			}
		},
		mounted(){
			this.getCityInfo()
		}
	}
	
</script>

<style>
</style>